package zuoye2;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class DemoArrayListNames {
    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("黄老邪");
        one.add("陈玄风");
        one.add("梅超风");
        one.add("陆乘风");
        one.add("曲灵风");
        one.add("武眠风");
        one.add("冯默风");
        one.add("罗玉风");
        List<String> two = new ArrayList<>();
        two.add("张三丰");
        two.add("宋远桥");
        two.add("俞莲舟");
        two.add("俞岱岩");
        two.add("张松溪");
        two.add("张翠山");
        two.add("殷梨亭");
        two.add("莫张谷");
        //只要三个字
        one.stream().filter(string -> string.length()==3).forEach(s-> System.out.println(s));
        System.out.println("==========================");
        //筛选后只要前三个人
        one.stream().filter(string -> string.length()==3).limit(3).forEach(s-> System.out.println(s));
         System.out.println("==========================");
        //2.只要姓张的
         two.stream().filter(string ->string.startsWith("张")).forEach(s-> System.out.println(s));
           System.out.println("==========================");
         //筛选后不要前两个
         two.stream().filter(string ->string.startsWith("张")).skip(2).forEach(s-> System.out.println(s));
          System.out.println("==========================");
         //把两个队伍合成一个
        Stream<String> stream1 = one.stream();
        Stream<String> stream2 = two.stream();
        Stream<String> concat = Stream.concat(stream1, stream2);
        concat.forEach(string -> System.out.println(string));
         System.out.println("==========================");





    }
}